package com.esteel.settlement.dao;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import com.esteel.settlement.entity.TbSettAccount;
import com.esteel.settlement.entity.TbSettAccountPK;

/**
 * 账户数据处理表
 * @author zhangxiuzhi
 *
 */
public interface SettAccountRepository extends JpaRepository<TbSettAccount, TbSettAccountPK>,JpaSpecificationExecutor<TbSettAccount> {

	@Query("select t from TbSettAccount t where t.id.custAcctId=?1")
	public TbSettAccount findByCustAcctId(String custAcctId);

	@Query("select t from TbSettAccount t where t.id.thirdCustId=?1")
	public TbSettAccount findByThirdCustId(String thirdCustId);
	
	@Query(value="select u.customer_key from tb_cus_firm u where u.customer_id=?1",nativeQuery=true)
	public Long thirdIdSize(String thirdCustId);
	
	/**
	 * 根据customer_key获得组织机构代码证
	 * @param customerKey
	 * @return
	 */
	@Query(value="select u.papers_num from tb_cus_firm_affix_chg u where u.customer_key=?1 and u.affix_kind='E'",nativeQuery=true)
	public String getOrgCode(long customerKey);
}
